/****************************************************
文件：FacingCamera.cs
作者：UnitySir
邮箱：zouajck@foxmail.com
日期：2021/03/22 20:24:37
功能：Nothing
*****************************************************/

using System;
using System.Collections;
using System.Collections.Generic;
using DSFramework;
using UnityEngine;

public class FacingCamera : MonoBehaviour
{
    private Transform[] _childs;
    private Transform _camera;

    private void Start()
    {
        _camera = MBE.GetTrans4Tag("RoleCamera");

        _childs = new Transform[transform.childCount];
        for (int i = 0; i < transform.childCount; i++)
        {
            _childs[i] = transform.GetChild(i);
        }

        DSEntity.Mono.AddUpdate("FacingCameraUpdate", OnUpdate);
    }

    void OnUpdate()
    {
        for (int i = 0; i < _childs.Length; i++)
        {
            _childs[i].rotation = _camera.rotation;
        }
    }
}